package com.miyake.loveviewweb.client.plugin;

import com.google.appengine.api.datastore.Key;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.miyake.loveviewweb.client.dialog.BasicDialog;
import com.miyake.loveviewweb.client.dialog.IDialogCreator;
import com.miyake.loveviewweb.client.service.DataService;

public class PluginRegisterDialogCreator implements IDialogCreator {

    public void show(String defaultName) {
        new BasicDialog(new PluginRegister(defaultName)) {

            @Override
            protected void onOK(Composite composite) {
                String text = ((PluginRegister)composite).getText();
                DataService.Util.getInstance().registerPlugin(text, new AsyncCallback<Key>() {

                    public void onFailure(Throwable caught) {
                        // TODO Auto-generated method stub
                        
                    }

                    public void onSuccess(Key result) {
                        Window.alert("Registered");
                    }
                    
                });
 //               serviceWrapper.createChart(name, serviceWrapper.getSelectedData().getKey());
            }
        }.showDialog();
    }

}
